#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
int main(void){
	set<vector<int>> st;
	int n;
    scanf("%d",&n);
	for(int i = 0;i < n;i++){
        vector<int> v;
	    for(int j = 0,x;j < 5;j++){
            cin >> x;
	        v.push_back(x);
	    }
	    sort(v.begin(),v.end());
        if(st.count(v)){
            cout << "pass" << endl;
        }else{
            st.insert(v);
            cout<< "buy" <<endl;
        }
	}
	return 0;
}
